//
//  TripDetailHeaderView.m
//  Traveling
//
//  Created by 曹秀云 on 15/6/21.
//  Copyright (c) 2015年 长沙市岳麓区立早网络科技有限公司. All rights reserved.
//

#import "TripDetailHeaderView.h"

@interface TripDetailHeaderView()
@property (weak, nonatomic) IBOutlet UILabel *tripNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *daysLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;

@end
@implementation TripDetailHeaderView

+(instancetype)headerView{
    return [[[NSBundle mainBundle] loadNibNamed:@"TripDetailHeaderView" owner:nil options:nil] lastObject];
}

-(void)setOrderResult:(TripOrderResult *)orderResult{
    _orderResult = orderResult;
    self.tripNameLabel.text = orderResult.plan_name;
    self.dateLabel.text = [NSString stringWithFormat:@"%@至%@",[TripDetailHeaderView dateString:orderResult.plan_start],[TripDetailHeaderView dateString:orderResult.plan_end]];
    self.daysLabel.text = [NSString stringWithFormat:@"天数：%ld",orderResult.day_num];
    self.priceLabel.text = [NSString stringWithFormat:@"￥%.2f",orderResult.price];
}

+(NSString *)dateString:(NSString *)dataStr{
    NSString *string = dataStr;
    NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
    [inputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *inputDate = [inputFormatter dateFromString:string];
    [inputFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *date = [inputFormatter stringFromDate:inputDate];
    return date;
}


@end
